package com.huaxinkaiye.adapter;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;

import com.android.volley.toolbox.NetworkImageView;
import com.google.gson.Gson;
import com.huaxinkaiye.R;
import com.huaxinkaiye.adapter.ShenPiAdapter.ViewHolder;
import com.huaxinkaiye.application.HuaXinApplication;
import com.huaxinkaiye.bean.PictureRows;
import com.huaxinkaiye.bean.RowsBean;
import com.huaxinkaiye.utils.SimpleClient;
import com.huaxinkaiye.utils.UrlUtils;

import android.content.Context;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ShenPiListAdapter extends BaseAdapter {
	private Context context;
	public ArrayList<RowsBean> rows = new ArrayList<RowsBean>();
	public String url ;
	public ShenPiListAdapter(Context context) {
		// TODO Auto-generated constructor stub
		this.context = context;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return rows.size();
	}

	public void add(ArrayList<RowsBean> rows) {
		this.rows.addAll(rows);
	}

	public void clear() {
		this.rows.clear();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return this.rows.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int arg0, View convertView, ViewGroup arg2) {
		// TODO Auto-generated method stub
		ViewHolder holder;
		if (convertView == null) {
			convertView = LayoutInflater.from(context).inflate(
					R.layout.shenpi_item, null);
			holder = new ViewHolder();
			convertView.setTag(holder);
			holder.im_zhuangtai=(ImageView)convertView
					.findViewById(R.id.im_zhuangtai);
			holder.te_who = (TextView) convertView.findViewById(R.id.te_who);
			holder.te_zhuangtai = (TextView) convertView
					.findViewById(R.id.te_zhuangtai);
			holder.te_time = (TextView) convertView
					.findViewById(R.id.te_time);
//			holder.te_chulizhuangtai = (TextView) convertView
//					.findViewById(R.id.te_chulizhuangtai);
			holder.te_jiage= (TextView) convertView
					.findViewById(R.id.te_jiage);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		
		holder.te_who.setText(rows.get(arg0).getPlateNumber());
		holder.te_time.setText(rows.get(arg0).barginRequestTime);
		if(rows.get(arg0).getBarginAudit()==1){
			holder.te_zhuangtai.setText("提交议价申请");
		}
		if(rows.get(arg0).getBarginAudit()==2){
			holder.te_zhuangtai.setText("提交议价审核");
		}
		if(rows.get(arg0).getBarginAudit()==3){
			holder.te_zhuangtai.setText("提交成交申请");
		}
		if(rows.get(arg0).getBarginAudit()==4){
			holder.te_zhuangtai.setText("提交成交审核");
		}
		if(rows.get(arg0).getBarginAudit()==5){
			holder.te_zhuangtai.setText("残值发放");
		}
		//holder.te_chulizhuangtai.setText(rows.get(arg0).getBarginType().getMean());
		holder.te_jiage.setText(rows.get(arg0).getBarginAmount()+"");
		return convertView;
	}

	public class ViewHolder {
		ImageView im_zhuangtai;
		TextView  te_who, te_zhuangtai,te_time,te_chulizhuangtai,te_jiage;
	}
}
